* Technical validation - comparing female legislators (FemShare) with external data (ShareWomen)

* Import "LALD" file in .xlsx or .dta

import excel "/Users/PathFile/LALD.xlsx", sheet("Sheet1") firstrow
use "/Users/PathFile/LALD.dta"

* Generating new variable for counting the number of female legislators
gen Women = Female == 1
collapse (sum) Women (count) TotalLegislators = Female, by(Country CountryID ElectionYear ChamberType)

* Calculate Share of female legislators
gen FemShare = Women / TotalLegislators * 100

rename ElectionYear Year

gen ShareWomen = .
replace ShareWomen = 3.9 if CountryID == 11 & Year == 1983 & ChamberType == 0
replace ShareWomen = 4.7 if CountryID == 11 & Year == 1987 & ChamberType == 0
replace ShareWomen = 6.3 if CountryID == 11 & Year == 1989 & ChamberType == 0
replace ShareWomen = 5.8 if CountryID == 11 & Year == 1991 & ChamberType == 0
replace ShareWomen = 25.3 if CountryID == 11 & Year == 1995 & ChamberType == 0
replace ShareWomen = 26.5 if CountryID == 11 & Year == 1999 & ChamberType == 0
replace ShareWomen = 30.7 if CountryID == 11 & Year == 2001 & ChamberType == 0
replace ShareWomen = 35.4 if CountryID == 11 & Year == 2005 & ChamberType == 0
replace ShareWomen = 40 if CountryID == 11 & Year == 2007 & ChamberType == 0
replace ShareWomen = 38.5 if CountryID == 11 & Year == 2009 & ChamberType == 0
replace ShareWomen = 37.4 if CountryID == 11 & Year == 2011 & ChamberType == 0
replace ShareWomen = 36.6 if CountryID == 11 & Year == 2013 & ChamberType == 0
replace ShareWomen = 35.8 if CountryID == 11 & Year == 2015 & ChamberType == 0
replace ShareWomen = 38.1 if CountryID == 11 & Year == 2017 & ChamberType == 0
replace ShareWomen = 38.9 if CountryID == 11 & Year == 2019 & ChamberType == 0
replace ShareWomen = 44.7 if CountryID == 11 & Year == 2021 & ChamberType == 0
replace ShareWomen = 43.2 if CountryID == 11 & Year == 2023 & ChamberType == 0

replace ShareWomen = 33.3 if CountryID == 11 & Year == 2001 & ChamberType == 1
replace ShareWomen = 41.7 if CountryID == 11 & Year == 2005 & ChamberType == 1
replace ShareWomen = 38.9 if CountryID == 11 & Year == 2007 & ChamberType == 1
replace ShareWomen = 37.5 if CountryID == 11 & Year == 2009 & ChamberType == 1
replace ShareWomen = 38.9 if CountryID == 11 & Year == 2011 & ChamberType == 1
replace ShareWomen = 41.7 if CountryID == 11 & Year == 2015 & ChamberType == 1
replace ShareWomen = 43.1 if CountryID == 11 & Year == 2021 & ChamberType == 1
replace ShareWomen = 45.8 if CountryID == 11 & Year == 2023 & ChamberType == 1

replace ShareWomen = 0.8 if CountryID == 12 & Year == 1980 & ChamberType == 0
replace ShareWomen = 3.1 if CountryID == 12 & Year == 1985 & ChamberType == 0
replace ShareWomen = 9.2 if CountryID == 12 & Year == 1989 & ChamberType == 0
replace ShareWomen = 10.8 if CountryID == 12 & Year == 1993 & ChamberType == 0
replace ShareWomen = 6.9 if CountryID == 12 & Year == 1997 & ChamberType == 0
replace ShareWomen = 18.5 if CountryID == 12 & Year == 2002 & ChamberType == 0
replace ShareWomen = 16.9 if CountryID == 12 & Year == 2005 & ChamberType == 0
replace ShareWomen = 22.3 if CountryID == 12 & Year == 2009 & ChamberType == 0
replace ShareWomen = 25.4 if CountryID == 12 & Year == 2014 & ChamberType == 0
replace ShareWomen = 46.2 if CountryID == 12 & Year == 2020 & ChamberType == 0

replace ShareWomen = 7.4 if CountryID == 12 & Year == 1980 & ChamberType == 1
replace ShareWomen = 3.7 if CountryID == 12 & Year == 1989 & ChamberType == 1
replace ShareWomen = 14.8 if CountryID == 12 & Year == 2002 & ChamberType == 1
replace ShareWomen = 3.7 if CountryID == 12 & Year == 2005 & ChamberType == 1
replace ShareWomen = 41.7 if CountryID == 12 & Year == 2009 & ChamberType == 1
replace ShareWomen = 47.2 if CountryID == 12 & Year == 2014 & ChamberType == 1
replace ShareWomen = 55.6 if CountryID == 12 & Year == 2020 & ChamberType == 1

replace ShareWomen = 5.7 if CountryID == 13 & Year == 1998 & ChamberType == 0
replace ShareWomen = 8.6 if CountryID == 13 & Year == 2002 & ChamberType == 0
replace ShareWomen = 8.8 if CountryID == 13 & Year == 2006 & ChamberType == 0
replace ShareWomen = 8.6 if CountryID == 13 & Year == 2010 & ChamberType == 0
replace ShareWomen = 9.9 if CountryID == 13 & Year == 2014 & ChamberType == 0
replace ShareWomen = 15 if CountryID == 13 & Year == 2018 & ChamberType == 0
replace ShareWomen = 17.7 if CountryID == 13 & Year == 2022 & ChamberType == 0

replace ShareWomen = 2.5 if CountryID == 13 & Year == 1990 & ChamberType == 1
replace ShareWomen = 7.4 if CountryID == 13 & Year == 1994 & ChamberType == 1
replace ShareWomen = 12.3 if CountryID == 13 & Year == 2002 & ChamberType == 1
replace ShareWomen = 14.8 if CountryID == 13 & Year == 2006 & ChamberType == 1
replace ShareWomen = 16 if CountryID == 13 & Year == 2010 & ChamberType == 1
replace ShareWomen = 13.6 if CountryID == 13 & Year == 2014 & ChamberType == 1
replace ShareWomen = 13.6 if CountryID == 13 & Year == 2018 & ChamberType == 1
replace ShareWomen = 16 if CountryID == 13 & Year == 2022 & ChamberType == 1

replace ShareWomen = 10.2 if CountryID == 14 & Year == 1991 & ChamberType == 0
replace ShareWomen = 10.8 if CountryID == 14 & Year == 1994 & ChamberType == 0
replace ShareWomen = 11.8 if CountryID == 14 & Year == 1998 & ChamberType == 0
replace ShareWomen = 12 if CountryID == 14 & Year == 2002 & ChamberType == 0
replace ShareWomen = 8.4 if CountryID == 14 & Year == 2006 & ChamberType == 0
replace ShareWomen = 12.7 if CountryID == 14 & Year == 2010 & ChamberType == 0
replace ShareWomen = 12.1 if CountryID == 14 & Year == 2014 & ChamberType == 0
replace ShareWomen = 15.1 if CountryID == 14 & Year == 2018 & ChamberType == 0
replace ShareWomen = 28.9 if CountryID == 14 & Year == 2022 & ChamberType == 0

replace ShareWomen = 6.9 if CountryID == 14 & Year == 1994 & ChamberType == 1
replace ShareWomen = 12.7 if CountryID == 14 & Year == 1998 & ChamberType == 1
replace ShareWomen = 8.8 if CountryID == 14 & Year == 2002 & ChamberType == 1
replace ShareWomen = 11.8 if CountryID == 14 & Year == 2006 & ChamberType == 1
replace ShareWomen = 15.7 if CountryID == 14 & Year == 2010 & ChamberType == 1
replace ShareWomen = 16 if CountryID == 14 & Year == 2014 & ChamberType == 1
replace ShareWomen = 20.4 if CountryID == 14 & Year == 2018 & ChamberType == 1
replace ShareWomen = 30.2 if CountryID == 14 & Year == 2022 & ChamberType == 1

replace ShareWomen = 7 if CountryID == 15 & Year == 1978 & ChamberType == 0
replace ShareWomen = 10.5 if CountryID == 15 & Year == 1986 & ChamberType == 0
replace ShareWomen = 12.3 if CountryID == 15 & Year == 1990 & ChamberType == 0
replace ShareWomen = 14 if CountryID == 15 & Year == 1994 & ChamberType == 0
replace ShareWomen = 19.3 if CountryID == 15 & Year == 1998 & ChamberType == 0
replace ShareWomen = 31.6 if CountryID == 15 & Year == 2002 & ChamberType == 0
replace ShareWomen = 38.6 if CountryID == 15 & Year == 2006 & ChamberType == 0
replace ShareWomen = 36.8 if CountryID == 15 & Year == 2010 & ChamberType == 0
replace ShareWomen = 33.3 if CountryID == 15 & Year == 2014 & ChamberType == 0
replace ShareWomen = 45.6 if CountryID == 15 & Year == 2018 & ChamberType == 0
replace ShareWomen = 47.4 if CountryID == 15 & Year == 2022 & ChamberType == 0

replace ShareWomen = 16.1 if CountryID == 16 & Year == 1998 & ChamberType == 0
replace ShareWomen = 17.3 if CountryID == 16 & Year == 2002 & ChamberType == 0
replace ShareWomen = 19.7 if CountryID == 16 & Year == 2006 & ChamberType == 0
replace ShareWomen = 20.8 if CountryID == 16 & Year == 2010 & ChamberType == 0
replace ShareWomen = 20 if CountryID == 16 & Year == 2016 & ChamberType == 0
replace ShareWomen = 27.9 if CountryID == 16 & Year == 2020 & ChamberType == 0

replace ShareWomen = 3.3 if CountryID == 16 & Year == 1994 & ChamberType == 1
replace ShareWomen = 6.7 if CountryID == 16 & Year == 1998 & ChamberType == 1
replace ShareWomen = 3.1 if CountryID == 16 & Year == 2002 & ChamberType == 1
replace ShareWomen = 9.4 if CountryID == 16 & Year == 2010 & ChamberType == 1
replace ShareWomen = 12.5 if CountryID == 16 & Year == 2020 & ChamberType == 1

replace ShareWomen = 0 if CountryID == 17 & Year == 1979 & ChamberType == 0
replace ShareWomen = 4.2 if CountryID == 17 & Year == 1984 & ChamberType == 0
replace ShareWomen = 1.4 if CountryID == 17 & Year == 1986 & ChamberType == 0
replace ShareWomen = 4.5 if CountryID == 17 & Year == 1988 & ChamberType == 0
replace ShareWomen = 7.5 if CountryID == 17 & Year == 1990 & ChamberType == 0
replace ShareWomen = 6 if CountryID == 17 & Year == 1992 & ChamberType == 0
replace ShareWomen = 4.5 if CountryID == 17 & Year == 1994 & ChamberType == 0
replace ShareWomen = 17.4 if CountryID == 17 & Year == 1998 & ChamberType == 0
replace ShareWomen = 16 if CountryID == 17 & Year == 2002 & ChamberType == 0
replace ShareWomen = 25 if CountryID == 17 & Year == 2006 & ChamberType == 0
replace ShareWomen = 32.3 if CountryID == 17 & Year == 2009 & ChamberType == 0
replace ShareWomen = 38.7 if CountryID == 17 & Year == 2013 & ChamberType == 0
replace ShareWomen = 38 if CountryID == 17 & Year == 2017 & ChamberType == 0
replace ShareWomen = 38 if CountryID == 17 & Year == 2021 & ChamberType == 0
replace ShareWomen = 43.1 if CountryID == 17 & Year == 2023 & ChamberType == 0

replace ShareWomen = 6.7 if CountryID == 18 & Year == 1985 & ChamberType == 0
replace ShareWomen = 11.7 if CountryID == 18 & Year == 1988 & ChamberType == 0
replace ShareWomen = 8.3 if CountryID == 18 & Year == 1991 & ChamberType == 0
replace ShareWomen = 10.7 if CountryID == 18 & Year == 1994 & ChamberType == 0
replace ShareWomen = 15.5 if CountryID == 18 & Year == 1997 & ChamberType == 0
replace ShareWomen = 9.5 if CountryID == 18 & Year == 2000 & ChamberType == 0
replace ShareWomen = 10.7 if CountryID == 18 & Year == 2003 & ChamberType == 0
replace ShareWomen = 16.7 if CountryID == 18 & Year == 2006 & ChamberType == 0
replace ShareWomen = 19 if CountryID == 18 & Year == 2009 & ChamberType == 0
replace ShareWomen = 26.2 if CountryID == 18 & Year == 2012 & ChamberType == 0
replace ShareWomen = 32.1 if CountryID == 18 & Year == 2015 & ChamberType == 0
replace ShareWomen = 31 if CountryID == 18 & Year == 2018 & ChamberType == 0
replace ShareWomen = 27.4 if CountryID == 18 & Year == 2021 & ChamberType == 0

replace ShareWomen = 7 if CountryID == 19 & Year == 1985 & ChamberType == 0
replace ShareWomen = 5.2 if CountryID == 19 & Year == 1990 & ChamberType == 0
replace ShareWomen = 7.5 if CountryID == 19 & Year == 1994 & ChamberType == 0
replace ShareWomen = 12.5 if CountryID == 19 & Year == 1995 & ChamberType == 0
replace ShareWomen = 7.1 if CountryID == 19 & Year == 1999 & ChamberType == 0
replace ShareWomen = 8.2 if CountryID == 19 & Year == 2003 & ChamberType == 0
replace ShareWomen = 12 if CountryID == 19 & Year == 2007 & ChamberType == 0
replace ShareWomen = 13.3 if CountryID == 19 & Year == 2011 & ChamberType == 0
replace ShareWomen = 13.9 if CountryID == 19 & Year == 2015 & ChamberType == 0
replace ShareWomen = 19.4 if CountryID == 19 & Year == 2019 & ChamberType == 0
replace ShareWomen = 20 if CountryID == 19 & Year == 2023 & ChamberType == 0

replace ShareWomen = 7.8 if CountryID == 20 & Year == 1997 & ChamberType == 0
replace ShareWomen = 5.5 if CountryID == 20 & Year == 2001 & ChamberType == 0
replace ShareWomen = 23.4 if CountryID == 20 & Year == 2005 & ChamberType == 0
replace ShareWomen = 18 if CountryID == 20 & Year == 2009 & ChamberType == 0
replace ShareWomen = 25.8 if CountryID == 20 & Year == 2013 & ChamberType == 0
replace ShareWomen = 21.1 if CountryID == 20 & Year == 2017 & ChamberType == 0
replace ShareWomen = 27.3 if CountryID == 20 & Year == 2021 & ChamberType == 0

replace ShareWomen = 5.8 if CountryID == 21 & Year == 1989 & ChamberType == 0
replace ShareWomen = 7.5 if CountryID == 21 & Year == 1993 & ChamberType == 0
replace ShareWomen = 10.8 if CountryID == 21 & Year == 1997 & ChamberType == 0
replace ShareWomen = 12.5 if CountryID == 21 & Year == 2001 & ChamberType == 0
replace ShareWomen = 15 if CountryID == 21 & Year == 2005 & ChamberType == 0
replace ShareWomen = 14.2 if CountryID == 21 & Year == 2009 & ChamberType == 0
replace ShareWomen = 15.8 if CountryID == 21 & Year == 2013 & ChamberType == 0
replace ShareWomen = 12.3 if CountryID == 21 & Year == 2017 & ChamberType == 0
replace ShareWomen = 35.5 if CountryID == 21 & Year == 2021 & ChamberType == 0

replace ShareWomen = 6.4 if CountryID == 21 & Year == 1989 & ChamberType == 1
replace ShareWomen = 6.5 if CountryID == 21 & Year == 1993 & ChamberType == 1
replace ShareWomen = 4.1 if CountryID == 21 & Year == 1997 & ChamberType == 1
replace ShareWomen = 4.2 if CountryID == 21 & Year == 2005 & ChamberType == 1
replace ShareWomen = 13.2 if CountryID == 21 & Year == 2009 & ChamberType == 1
replace ShareWomen = 18.4 if CountryID == 21 & Year == 2013 & ChamberType == 1
replace ShareWomen = 14 if CountryID == 21 & Year == 2017 & ChamberType == 1
replace ShareWomen = 24 if CountryID == 21 & Year == 2021 & ChamberType == 1

replace ShareWomen = 48.2 if CountryID == 22 & Year == 2018 & ChamberType == 0
replace ShareWomen = 50 if CountryID == 22 & Year == 2021 & ChamberType == 0

replace ShareWomen = 16.3 if CountryID == 23 & Year == 1990 & ChamberType == 0
replace ShareWomen = 9.7 if CountryID == 23 & Year == 1996 & ChamberType == 0
replace ShareWomen = 20.7 if CountryID == 23 & Year == 2001 & ChamberType == 0
replace ShareWomen = 15.2 if CountryID == 23 & Year == 2006 & ChamberType == 0
replace ShareWomen = 40.2 if CountryID == 23 & Year == 2011 & ChamberType == 0
replace ShareWomen = 45.7 if CountryID == 23 & Year == 2016 & ChamberType == 0
replace ShareWomen = 50.5 if CountryID == 23 & Year == 2021 & ChamberType == 0

replace ShareWomen = 8.3 if CountryID == 24 & Year == 1994 & ChamberType == 0
replace ShareWomen = 9.7 if CountryID == 24 & Year == 1999 & ChamberType == 0
replace ShareWomen = 16.7 if CountryID == 24 & Year == 2004 & ChamberType == 0
replace ShareWomen = 8.5 if CountryID == 24 & Year == 2009 & ChamberType == 0
replace ShareWomen = 19.3 if CountryID == 24 & Year == 2014 & ChamberType == 0
replace ShareWomen = 21.4 if CountryID == 24 & Year == 2019 & ChamberType == 0

replace ShareWomen = 10 if CountryID == 25 & Year == 1998 & ChamberType == 0
replace ShareWomen = 12.5 if CountryID == 25 & Year == 2008 & ChamberType == 0
replace ShareWomen = 17.5 if CountryID == 25 & Year == 2013 & ChamberType == 0
replace ShareWomen = 13.8 if CountryID == 25 & Year == 2018 & ChamberType == 0
replace ShareWomen = 22.5 if CountryID == 25 & Year == 2023 & ChamberType == 0

replace ShareWomen = 12.2 if CountryID == 25 & Year == 1998 & ChamberType == 1
replace ShareWomen = 8.9 if CountryID == 25 & Year == 2003 & ChamberType == 1
replace ShareWomen = 15.6 if CountryID == 25 & Year == 2008 & ChamberType == 1
replace ShareWomen = 20 if CountryID == 25 & Year == 2013 & ChamberType == 1
replace ShareWomen = 20 if CountryID == 25 & Year == 2018 & ChamberType == 1
replace ShareWomen = 24.4 if CountryID == 25 & Year == 2023 & ChamberType == 1

replace ShareWomen = 7.2 if CountryID == 26 & Year == 1980 & ChamberType == 0
replace ShareWomen = 5.6 if CountryID == 26 & Year == 1985 & ChamberType == 0
replace ShareWomen = 6.7 if CountryID == 26 & Year == 1990 & ChamberType == 0
replace ShareWomen = 10 if CountryID == 26 & Year == 1995 & ChamberType == 0
replace ShareWomen = 20 if CountryID == 26 & Year == 2000 & ChamberType == 0
replace ShareWomen = 18.3 if CountryID == 26 & Year == 2001 & ChamberType == 0
replace ShareWomen = 29.2 if CountryID == 26 & Year == 2006 & ChamberType == 0
replace ShareWomen = 21.5 if CountryID == 26 & Year == 2011 & ChamberType == 0
replace ShareWomen = 26.2 if CountryID == 26 & Year == 2016 & ChamberType == 0
replace ShareWomen = 26.2 if CountryID == 26 & Year == 2020 & ChamberType == 0

replace ShareWomen = 0 if CountryID == 27 & Year == 1984 & ChamberType == 0
replace ShareWomen = 6.1 if CountryID == 27 & Year == 1989 & ChamberType == 0
replace ShareWomen = 7.1 if CountryID == 27 & Year == 1994 & ChamberType == 0
replace ShareWomen = 12.1 if CountryID == 27 & Year == 1999 & ChamberType == 0
replace ShareWomen = 14.1 if CountryID == 27 & Year == 2009 & ChamberType == 0
replace ShareWomen = 13.1 if CountryID == 27 & Year == 2014 & ChamberType == 0
replace ShareWomen = 19.2 if CountryID == 27 & Year == 2019 & ChamberType == 0

replace ShareWomen = 0 if CountryID == 27 & Year == 1984 & ChamberType == 1
replace ShareWomen = 0 if CountryID == 27 & Year == 1989 & ChamberType == 1
replace ShareWomen = 6.7 if CountryID == 27 & Year == 1994 & ChamberType == 1
replace ShareWomen = 9.7 if CountryID == 27 & Year == 1999 & ChamberType == 1
replace ShareWomen = 13.3 if CountryID == 27 & Year == 2009 & ChamberType == 1
replace ShareWomen = 6.5 if CountryID == 27 & Year == 2014 & ChamberType == 1
replace ShareWomen = 26.7 if CountryID == 27 & Year == 2019 & ChamberType == 1

replace ShareWomen = 9.7 if CountryID == 28 & Year == 2000 & ChamberType == 0
replace ShareWomen = 17.4 if CountryID == 28 & Year == 2005 & ChamberType == 0

replace ShareWomen = 17 if CountryID == 28 & Year == 2010 & ChamberType == 0
replace ShareWomen = 14.4 if CountryID == 28 & Year == 2015 & ChamberType == 0

gen Difference = ShareWomen - FemShare

pwcorr ShareWomen FemShare
scatter ShareWomen FemShare
